<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
</head>
<body>
	<input type="text" value="我是文本框" id="btn1">
	<input type="button" value="点击按钮" id="btn">
	<ul id="ul">
		<li>1</li>
		<li>2</li>
		<li>3</li>
		<li>4</li>
	</ul>
	<!-- 阻止超链接的默认跳转 使用 onclick="return false" 来实现 -->
	<a href="http://www.baidu.com" onclick="return false">百度</a>

	<script>

		var uls  = document.getElementById('ul');
		var btn = document.getElementById('btn');
		var lis = uls.children;

		btn.onclick = function(){
			for(var i=0;i<lis.length;i++){
				// if(i%2 ==0){
				// 	lis[i].style.backgroundColor = "red"
				// }else{
				// 	lis[i].style.backgroundColor = "yellow"
				// }

				i%2 ==0?lis[i].style.backgroundColor = "red":lis[i].style.backgroundColor = "yellow"

			}	
		}


		btn1.onclick = function(){
			this.disabled = true
		}


	</script>
</body>
</html>	